package com.liruo.treasureattic.common.httpmsg.exception;

import com.liruo.treasureattic.common.httpmsg.result.Errno;

import java.io.Serial;

/**
 * @Author:liruo
 * @Date:2022-10-11-21:35:55
 * @Desc
 * 只有code和message传就都抛出这个异常，其他就不要了
 * 除非要特殊的值，然后可以让其继承AbstractResultException
 */
public class CommonResultException extends RuntimeException {
    @Serial
    private static final long serialVersionUID = 6595511158379138274L;
    private final int code;
    public CommonResultException(int code, String message) {
        super(message);
        this.code = code;
    }
    public CommonResultException(Errno code, String message) {
        this(code.getCode(),code.getMsg() + ", " + message);
    }

    public CommonResultException(Errno code) {
        this(code.getCode(), code.getMsg());
    }
    public int getCode() {
        return code;
    }
}
